//
//  TKL_CircleBtomView.m
//  TKL_EnPro
//
//  Created by 雅恩三河科技 on 2018/12/11.
//  Copyright © 2018年 MrZhang. All rights reserved.
//

#import "TKL_CircleBtomView.h"

@interface TKL_CircleBtomView ()
@property(nonatomic,strong)UITextField* praiseTF;
@property(nonatomic,strong)UITextField* collectTF;
@property(nonatomic,strong)UITextField* commentTF;
@end

@implementation TKL_CircleBtomView
#pragma mark - getter and setter


-(UITextField *)praiseTF
{
    if (!_praiseTF) {
        _praiseTF = [[UITextField alloc]init];
        _praiseTF.x=WFCGFloatX(0);
        _praiseTF.y=WFCGFloatY(0);
        _praiseTF.width=self.width/3;
        _praiseTF.height=self.height;
        _praiseTF.font = SYSTEMFONT(15);
        _praiseTF.textColor = HEXCOLOR(@"#999999");
        _praiseTF.text=@"1000";
        _praiseTF.enabled=NO;
        _praiseTF.returnKeyType=UIReturnKeySend;

        
        UIView* backView=[UIView new];
        backView.x=WFCGFloatX(0);
        backView.y=WFCGFloatY(0);
        backView.height=WFCGFloatY(30);
        backView.width=WFCGFloatX(30);
        backView.backgroundColor=[UIColor whiteColor];
        
        UIImageView* markIV=[UIImageView new];
        markIV.image=[UIImage imageNamed:@"praise"];
        markIV.width=markIV.image.size.width;
        markIV.height=markIV.image.size.height;
        markIV.x=WFCGFloatX(10);
        markIV.y=(_praiseTF.height-markIV.height)/2;
        [backView addSubview:markIV];
        _praiseTF.leftView=backView;
        _praiseTF.leftViewMode=UITextFieldViewModeAlways;
    }
    return _praiseTF;
}

-(UITextField *)collectTF
{
    if (!_collectTF) {
        _collectTF = [[UITextField alloc]init];
        _collectTF.x=self.width/3;
        _collectTF.y=WFCGFloatY(0);
        _collectTF.width=self.width/3;
        _collectTF.height=self.height;
        _collectTF.font = SYSTEMFONT(15);
        _collectTF.textColor = HEXCOLOR(@"#999999");;
        _collectTF.text=@"1000";
        _collectTF.enabled=NO;
        _collectTF.returnKeyType=UIReturnKeySend;
        
        
        
        
        UIView* backView=[UIView new];
        backView.x=WFCGFloatX(0);
        backView.y=WFCGFloatY(0);
        backView.height=WFCGFloatY(30);
        backView.width=WFCGFloatX(30);
        backView.backgroundColor=[UIColor whiteColor];
        
        UIImageView* markIV=[UIImageView new];
        markIV.image=[UIImage imageNamed:@"col"];
        markIV.width=markIV.image.size.width;
        markIV.height=markIV.image.size.height;
        markIV.x=WFCGFloatX(10);
        markIV.y=(_praiseTF.height-markIV.height)/2;
        [backView addSubview:markIV];
        _collectTF.leftView=backView;
        _collectTF.leftViewMode=UITextFieldViewModeAlways;
    }
    return _collectTF;
}
-(UITextField *)commentTF
{
    if (!_commentTF) {
        _commentTF = [[UITextField alloc]init];
        _commentTF.x=self.width/3*2;
        _commentTF.y=WFCGFloatY(0);
        _commentTF.width=self.width/3;
        _commentTF.height=self.height;
        _commentTF.font = SYSTEMFONT(15);
        _commentTF.textColor = HEXCOLOR(@"#999999");;
        _commentTF.text=@"1000";
        _commentTF.enabled=NO;
        _commentTF.returnKeyType=UIReturnKeySend;
        
        
        UIView* backView=[UIView new];
        backView.x=WFCGFloatX(0);
        backView.y=WFCGFloatY(0);
        backView.height=WFCGFloatY(30);
        backView.width=WFCGFloatX(30);
        backView.backgroundColor=[UIColor whiteColor];
        
        UIImageView* markIV=[UIImageView new];
        markIV.image=[UIImage imageNamed:@"comment"];
        markIV.width=markIV.image.size.width;
        markIV.height=markIV.image.size.height;
        markIV.x=WFCGFloatX(10);
        markIV.y=(_praiseTF.height-markIV.height)/2;
        [backView addSubview:markIV];
        _commentTF.leftView=backView;
        _commentTF.leftViewMode=UITextFieldViewModeAlways;
    }
    return _commentTF;
}

-(UIButton *)priseBtn
{
    if (!_priseBtn) {
        @WeakSelf;
        _priseBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        UIImage* image= [UIImage imageNamed:@"praise"];
        UIImage* imagesel= [UIImage imageNamed:@"praise_sel"];
        [_priseBtn setBackgroundImage:image forState:UIControlStateNormal];
        [_priseBtn setBackgroundImage:imagesel forState:UIControlStateSelected];
        _priseBtn.x=(self.width/3-image.size.width)/2;
        _priseBtn.y=(self.height-image.size.height)/2;
        _priseBtn.width=image.size.width;
        _priseBtn.height=image.size.height;
        [_priseBtn setEnlargeEdge:20];
        [_priseBtn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
            selfp.priseBtn.selected=!selfp.priseBtn.selected;
        }];
        

    }
    return _priseBtn;
}
-(UIButton *)colBtn
{
    if (!_colBtn) {
        @WeakSelf;
        _colBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        UIImage* image= [UIImage imageNamed:@"col"];
         UIImage* selimage= [UIImage imageNamed:@"col_sel"];
        [_colBtn setBackgroundImage:image forState:UIControlStateNormal];
         [_colBtn setBackgroundImage:selimage forState:UIControlStateSelected];
        _colBtn.x=(self.width/3-image.size.width)/2+self.width/3;
        _colBtn.y=(self.height-image.size.height)/2;
        _colBtn.width=image.size.width;
        _colBtn.height=image.size.height;
        [_colBtn setEnlargeEdge:20];
        [_colBtn handleControlEvent:UIControlEventTouchUpInside withBlock:^{
            selfp.colBtn.selected=!selfp.colBtn.selected;
        }];
        
    }
    return _colBtn;
}
-(UIButton *)commentBtn
{
    if (!_commentBtn) {
        _commentBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        UIImage* image= [UIImage imageNamed:@"comment"];
        [_commentBtn setBackgroundImage:image forState:UIControlStateNormal];
        _commentBtn.x=(self.width/3-image.size.width)/2+self.width/3*2;
        _commentBtn.y=(self.height-image.size.height)/2;
        _commentBtn.width=image.size.width;
        _commentBtn.height=image.size.height;
        [_commentBtn setEnlargeEdge:20];
    }
    return _commentBtn;
}
#pragma mark - event
#pragma mark - method
-(void)setDataSource:(NSMutableDictionary *)dataSource
{
    _praiseTF.text=[WFFunctions WFCheckEmptyBackStr:[dataSource objectForKey:@"praiseNumber"]];
    _commentTF.text=[WFFunctions WFCheckEmptyBackStr:[dataSource objectForKey:@"viewNumber"]];
    _collectTF.text=[WFFunctions WFCheckEmptyBackStr:[dataSource objectForKey:@"collectNumber"]];
}
#pragma mark - life
-(instancetype)init
{
    if (self = [super init])
    {
        self.width=WFCGFloatX(335);
        self.height=WFCGFloatY(30);
        
        [self addSubview:self.praiseTF];
        [self addSubview:self.commentTF];
        [self addSubview:self.collectTF];
    }
    return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
#pragma mark - delegate
@end
